package com.xiaotu.spider.aiman.pipeline;

import org.springframework.stereotype.Component;

import com.xiaotu.common.model.MovieFansDetail;
import com.xiaotu.common.model.MovieFansPeople;
import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.spider.APipeline;

import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;

/**
 * @类名 MovieAiManPipeline
 * @日期 2017年11月28日
 * @作者 王艳龙
 * @功能 艾漫电影pipeline
 */

@Component("MovieAiManPipeline")
public class MovieAiManPipeline extends APipeline
{
    @Override
    protected void doProcess(ResultItems resultItems, Task task)
    {
    	MovieFansDetail detail = resultItems.get(MovieFansDetail.class.getName());
        if (detail == null)
            return;
        String key = DataRedisKeyUtils.getKey(Constants.DataRedisKey.MOVIE_AIMAN_DETAIL_YYYYMMDD);
    	cacheHandler.hSet(key, detail.getTvId(), detail);
        cacheHandler.setCacheTimeout(key);
        
        MovieFansPeople people = resultItems.get(MovieFansPeople.class.getName());
        if (people == null)
            return;
        String key_art = DataRedisKeyUtils.getKey(Constants.DataRedisKey.MOVIE_AIMAN_PEOPLE_YYYYMMDD);
    	cacheHandler.hSet(key_art, people.getTvId(), people);
        cacheHandler.setCacheTimeout(key_art);
    }

}
